﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SchoolsBI;

public partial class Admin_Materias_MateriasCurso : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        cboCurso.seleciona += new cboSelected(cboCurso_seleciona);
        CboMateria.NameId = "idprofesormateria";
        CboMateria.NameDescript = "Materia";
        
     }
    
    void cboCurso_seleciona(string param1, string param2)
    {
        CboMateria.tabla = "Proc_ProfesoresMateriaDisponibles " + param1;
        CboMateria.TipoOrigen = Controles_cboGeneric.TipoSource.Procedure;
        
        CboMateria.BindCBO();
        ShowGridData();
            
    }
    private void ShowGridData()
    {
        GridView1.DataSource = MateriasCurso.Tabla("proc_MateriasCurso " + cboCurso.Value);
        GridView1.DataBind();
    }

    protected void cmdOk_Click(object sender, EventArgs e)
    {
        MateriasCurso mc = new MateriasCurso();
        mc.IdCurso = Convert.ToInt32( cboCurso.Value);
        mc.IdProfesorMateria = Convert.ToInt32(CboMateria.Value);
        mc.Crear();
        ShowGridData();
        
    }

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        MateriasCurso mc = MateriasCurso.Buscar("IdMateriaCurso=" + GridView1.DataKeys[e.RowIndex].Value);
        mc.Borrar();
        ShowGridData();
        
    }

}
